<!DOCTYPE html>
<html>

<head lang="en">
	<title>首页</title>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
	<script src="/js/jquery/jquery.min.js"></script>
	<script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
	<script src="/js/plugins/jrender/jrender.min.js"></script>
	<link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
	<link rel="stylesheet" href="/css/reset.css" rel="stylesheet" >
	<link rel="stylesheet" href="/css/index.css" rel="stylesheet">
	

	<script>
		$(function () {
            //全局搜索功能
            //搜索绑定点击事件
            /*$(".searchBtn").click(function () {
                var keyword = $(this).val();
                //keyword有值才跳转页面
                if (keyword){

                    window.location.href = "/searchResult.html?keyword="+encodeURI(keyword)
                }
            });*/


            $(".searchBtn").change(function () {
                var keyword = $(this).val();
                window.location.href = "/searchResult.html?keyword=" + keyword;
            });
            $(".searchBtn").click(function () {
                if ($(this).val()) {
                    $(this).change();
                }
            });


            /*if ($(".searchBtn").val()) {
                $(".searchBtn").change();
            }*/
		    //清除侧边栏的缓存
			$("#ipage").prop("src","/mine/simpleProfiles.html?"+new Date().getTime());

			$.get("/travels/commend",{type:1,pageSize:3},function (data) {
                $("#travelsCommends").renderValues(data,{
                    getHref:function (item,value) {
                        var href=$(item).data("href")
                        $(item).prop("href",href+value);
                    }
                })

				$(".carousel-item:first").addClass("active");
            })

            //查询出状态为热门的点评  lituan
            $.get("/strategyComments/1",function (data) {
                var hotComments={list:data}
                $("#comments").renderValues(hotComments,{
                    getHref: function (item, value) {
                        var href = $(item).data("href")
                        $(item).prop("href", href + value);
                    }
                })
            })

			//推荐日志1篇
            $.get("/news/content",{state:2,pageSize:3},function (data) {
                $(".news").renderValues(data.list[0],{
                    getHref:function (item,value) {
                        var href=$(item).data("href")
                        $(item).prop("href",href+value);
                    }
                })
            })
			//发布日志2篇
            $.get("/news/content",{state:1,pageSize:2},function (data) {
                $("#smaller").renderValues(data,{
                    getHref:function (item,value) {
                        var href=$(item).data("href")
                        $(item).prop("href",href+value);
                    }
                })
            })
        })
	</script>

</head>


<body>

<div class="body">
	<input type="checkbox" id="menu">

	<label for="menu" class="menu">
		<span><i class="fa fa-user fa-fw fa-2x"></i></span>
		<span><i class="fa fa-chevron-left fa-fw fa-2x" style="color: #3E3C3B"></i></span>
	</label>

	<!-- 侧边栏 -->
	<div class="nav">
		<!--iframe会有一个缓存 侧边栏-->
		<iframe id="ipage" frameborder="0" width="90%"></iframe>
	</div>

	<div class="search-head">
		<div class="row nav-search">
			<div class="col-2"></div>
			<div class="col-10">
				<div class="input-group-sm search">
					<input class="form-control searchBtn" placeholder="搜索旅行攻略、日记和旅游资讯">
                    <i class="fa fa-search" id="search"
                       style="color:white;font-size:25px;position: absolute;top: 23%;left: 92%">
                    </i>
				</div>
			</div>
		</div>
	</div>

	<div class="container">
        <!--&lt;!&ndash;音乐播放&ndash;&gt;-->
        <!--<div id="lanren" style="width: 100%;position: relative;">-->
            <!--<div id="audio-btn" class="on" onclick="lanren.changeClass(this,'media')" style="width: 33px;height: 33px;background-size: 100% 100%;position: absolute;z-index: 9999;right: 0px;top: -8px;margin: 0px;">-->
                <!--<audio loop="loop" src="/upload/videoAndMusic/2.mp3" id="media" preload="preload"></audio>-->
            <!--</div>-->
        <!--</div>-->
		<h6 class="module-title">每周推荐</h6>
		<div id="carouselExampleControls" class="carousel slide" data-ride="carousel">
			<div id="travelsCommends">
				<div class="carousel-inner" render-loop="list">
					<div class="carousel-item ">
						<a data-href="travelContent.html?id=" render-key="list.t_id" render-fun="getHref" >
							<img class="d-block w-100"  render-src="list.coverUrl" width="100%" height="200px">
							<span class="recommend" render-html="list.title"></span>
						</a>
						<div class="recommend-author">
							<a data-href="userProfiles.html?id=" render-key="list.u_id" render-fun="getHref" >
							<img  class="rounded-circle" style="width: 10%;" render-src="list.u_headImgUrl">
							<span render-html="list.u_name"></span>
							</a>在&nbsp;
							<span render-html="list.r_name"></span>
						</div>
					</div>
				</div>
			</div>
			<a class="carousel-control-prev" href="#carouselExampleControls" role="button" data-slide="prev">
				<span class="carousel-control-prev-icon" aria-hidden="true"></span>
				<span class="sr-only"></span>
			</a>
			<a class="carousel-control-next" href="#carouselExampleControls" role="button" data-slide="next">
				<span class="carousel-control-next-icon" aria-hidden="true"></span>
				<span class="sr-only"></span>
			</a>
		</div>
		<hr>

        <div class="row nav-box">
            <div class="col" style="background-color: #DFE823;" align="center">
                <a href="strategyPage.html"><i class="fa fa-plane fa-fw"></i> 找攻略</a>
            </div>
            <div class="col" style="background-color: #7281D5;" align="center">
                <a href="travelPage.html"><i class="fa fa-book fa-fw"></i> 看游记</a>
            </div>
        </div>
        <div class="row nav-box">
            <div class="col" style="background-color: #062c33;" align="center">
                <a href="/shopping/index.html"><i class="fa fa-map-marker "></i> 窝窝商城</a>
            </div>
            <div class="col" style="background-color: #732D2D;" align="center">
                <a href="companion.html"><i class="fa fa-user-plus "></i> 结伴</a>
            </div>
        </div>

        <div class="row dynamic " id="comments">
                <div class="col-1" style="padding: 0px;">
                    <img class="rounded" src="/img/topComment.png" style="width: 50px;">
                </div>
                <div class="col">
                    <div class="Marquee" render-loop="list">
                        <div class="d-flex">
                            <a data-href="userProfiles.html?id=" render-key="list.user.id" render-fun="getHref">
                                <img class="rounded-circle dynamic-head"
                                     render-src="list.user.headImgUrl">
                            </a>
                            <a data-href="/mine/strategyComment.html?id=" render-key="list.id" render-fun="getHref" class="dynamic-detail" >
                                <span render-html="list.user.nickName"></span> 点评了攻略<p render-html="list.strategy.title"></p>
                            </a>
                        </div>
                    </div>
                </div>
        </div>
    </div>

	<hr>

	<div class="container">
		<h6 class="module-title">骡窝日报 <a href="/newsPage.html">更多</a>  </h6>


        <div class="news " id="bigger">
            <div>
                <a data-href="newsContent.html?id=" render-key="id" render-fun="getHref">
                    <img width="100%" render-src="coverUrl">
                    <div class="caption">
                        <h5 render-html="title">暑假去哪里旅游凉快？</h5>
                        <p render-html="subTitle"></p>
                    </div>
                </a>
            </div>
        </div>

        <hr>
        <div id="smaller">
            <div render-loop="list">
                <div style="margin-bottom: 20px">
                    <a data-href="newsContent.html?id=" render-key="list.id" render-fun="getHref">
                        <div class="row news-detail">
                            <div class="col-5">
                                <img render-src="list.coverUrl">
                            </div>
                            <div class="col-7">
                                <h4 render-html="list.title"></h4>
                                <p render-html="list.subTitle"></p>
                            </div>
                        </div>
                    </a>
                    <hr>
                </div>
            </div>
        </div>
    </div>
</div>


<script>

        $(function () {
			showComments();
        })

		function showComments(){
			var Mar = document.getElementsByClassName("Marquee")[0];
			var child_div=Mar.getElementsByTagName("div");
			var picH = 50;//移动高度
			var scrollstep=3;//移动步幅,越大越快
			var scrolltime=20;//移动频度(毫秒)越大越慢
			var stoptime=3000;//间断时间(毫秒)
			var tmpH = 0;
			Mar.innerHTML += Mar.innerHTML;
			function start(){
				if(tmpH < picH){
					tmpH += scrollstep;
					if(tmpH > picH )tmpH = picH ;
					Mar.scrollTop = tmpH;
					setTimeout(start,scrolltime);
				}else{
					tmpH = 0;
					Mar.appendChild(child_div[0]);
					Mar.scrollTop = 0;
					setTimeout(start,stoptime);
				}
			}
			setTimeout(start,stoptime)
		}

       /* var lanren = {
            changeClass: function (target, id) {
                var className = $(target).attr('class');
                var ids = document.getElementById(id);
                (className == 'on')
                    ? $(target).removeClass('on').addClass('off')
                    : $(target).removeClass('off').addClass('on');
                (className == 'on')
                    ? ids.pause()
                    : ids.play();
            },
            play: function () {
                document.getElementById('media').play()
            }
        }
        lanren.play();*/
	</script>
<!--音乐播放-->
<style>
    * {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    #lanren #audio-btn {
        width: 44px;
        height: 44px;
        margin: 100px auto;
        background-size: 100% 100%;
    }

    #lanren .on {
        background: url('/upload/imges/music_on.png') no-repeat 0 0;
        -webkit-animation: rotating 1.2s linear infinite;
        animation: rotating 1.2s linear infinite;
    }

    #lanren .off {
        background: url('/upload/imges/music_off.png') no-repeat 0 0;
    }

    @-webkit-keyframes rotating {
        from {
            -webkit-transform: rotate(0deg);
            -moz-transform: rotate(0deg);
            -ms-transform: rotate(0deg);
            -o-transform: rotate(0deg);
            transform: rotate(0deg);
        }
        to {
            -webkit-transform: rotate(360deg);
            -moz-transform: rotate(360deg);
            -ms-transform: rotate(360deg);
            -o-transform: rotate(360deg);
            transform: rotate(360deg);
        }
    }

    @keyframes rotating {
        from {
            -webkit-transform: rotate(0deg);
            -moz-transform: rotate(0deg);
            -ms-transform: rotate(0deg);
            -o-transform: rotate(0deg);
            transform: rotate(0deg);
        }
        to {
            -webkit-transform: rotate(360deg);
            -moz-transform: rotate(360deg);
            -ms-transform: rotate(360deg);
            -o-transform: rotate(360deg);
            transform: rotate(360deg);
        }
    }
</style>
</body>

</html>